package com.zhanglei.method;

/**
 * @author caesar
 * @date 2025/7/5
 * @apiNote
 */
public class Triangle {
    public int a;
    public int b;
    public int c;

    public Triangle() {
    }

    public Triangle(int a, int b, int c) {
        if (a + b <= c || a + c <= b || b + c <= a || a < 0 || b < 0 || c < 0) {
            System.out.println("无法构成三角形");
        } else {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }

    public double getArea() {
        double p = (a + b + c) / 2.0;
        double area = Math.sqrt(p * (p - a) * (p - b) * (p - c));
        return area;
    }

    public double getPerimeter() {
        return a + b + c;
    }
}
